package com.github.lee.mvvm.core.util

import android.view.View
import androidx.databinding.BindingAdapter


@BindingAdapter("view_visible")
fun viewVisible(v: View, visible: Boolean?) {
    v.visibility = if (visible == true) {
        View.VISIBLE
    } else {
        View.INVISIBLE
    }
}

@BindingAdapter("view_gone")
fun viewGone(v: View?, gone: Boolean?) {
    v?.visibility = if (gone == true) {
        View.GONE
    } else {
        View.VISIBLE
    }
}

@BindingAdapter("view_click")
fun viewClick(v: View, block: ((View) -> Unit)?) {
    v.setOnClickListener(block)
}